package com.wanmait.hr.service.Impl;

import com.wanmait.hr.mapper.RecordMapper;
import com.wanmait.hr.service.RecordService;
import com.wanmait.hr.vo.Record;
import com.wanmait.hr.vo.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import java.sql.Timestamp;

import java.text.*;

import java.util.Date;

@Service
public class RecordServiceImpl implements RecordService {
    @Resource
    private RecordMapper recordMapper;
    @Override
    public void addRecord(User user, String  time) {//添加档案 "yyyy-MM-dd HH:mm:ss"
       String timex[]=time.split(" - ");
       String a=timex[0];
       String times []=a.split("/");
       String b=times[2]+"-"+times[0]+"-"+times[1];
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        format.setLenient(false);
        //要转换字符串 str_test
        try {
            Timestamp ts = new Timestamp(format.parse(b).getTime());
            recordMapper.addRecord(user,ts);
        } catch (ParseException e) {

            e.printStackTrace();
        }


    }

    @Override
    public Record checkRecord(int id) {// 查看个人档案---陈正儒
        return recordMapper.checkRecord(id);
    }
}
